import vtkmodules.all as vtk
from CloudEngine.core.BaseActor import BaseActor


class PointCloudActor(BaseActor):
    type = "GRAPHIC_ACTOR"
    created_by = "default"

    def __init__(self, poly_data, scalar_range: list):
        self.poly_data = poly_data
        self.mapper = vtk.vtkPolyDataMapper()
        glyphFilter = vtk.vtkVertexGlyphFilter()
        print("scalar_range", scalar_range)
        glyphFilter.AddInputData(poly_data)
        glyphFilter.Update()
        self.mapper.SetInputConnection(glyphFilter.GetOutputPort())
        self.mapper.SetScalarRange(scalar_range[0], scalar_range[1])
        self.instance = vtk.vtkActor()
        self.instance.GetProperty().SetPointSize(1)
        self.instance.SetMapper(self.mapper)
